package m.fun.model;

import m.base.model.StoreInfo;
import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import manage.model.StatusModel;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "tf_offer_info", description = "报价单信息")
public class OfferInfo extends StatusModel implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="user_oid",table= UserInfo.class,description="所属用户")
    private UserInfo user;
    @LinkTableMeta(name="store_oid",table= StoreInfo.class,description="所属商户")
    private StoreInfo store;
    @FieldMeta(name = "title",type = FieldType.STRING,length = 50,description = "标题")
    private String title;
    @FieldMeta(name = "description",type = FieldType.STRING,length = 200,description = "描述")
    private String description;
    @FieldMeta(name="contact",type= FieldType.STRING,length=20,description="联系人")
    private String contact;
    @FieldMeta(name="tel",type= FieldType.STRING,length=20,description="联系电话")
    private String tel;
    @FieldMeta(name="address",type= FieldType.STRING,length=300,description="联系地址")
    private String address;

    @FieldMeta(name="detail_num",type= FieldType.INT,description="报价商品数量")
    private Integer detailNum;
    @FieldMeta(name="view_num",type= FieldType.INT,defaultValue = "0",description="访问量")
    private Integer viewNum;

    public StoreInfo getStore() {
        return store;
    }

    public void setStore(StoreInfo store) {
        this.store = store;
    }

    public Integer getDetailNum() {
        return detailNum;
    }

    public void setDetailNum(Integer detailNum) {
        this.detailNum = detailNum;
    }

    public UserInfo getUser() {
        return user;
    }

    public void setUser(UserInfo user) {
        this.user = user;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getViewNum() {
        return viewNum;
    }

    public void setViewNum(Integer viewNum) {
        this.viewNum = viewNum;
    }
}
